<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  省份<input type="text" name="province" value="浙江省"> 城市<input type="text" name="city" value="杭州市">
  <button>测试</button>
  <ul></ul>

  <script src="./js/axios.js"></script>
  <script>
    const btn = document.querySelector('button');
    const provinceInput = document.querySelector('input[name=province]');
    const cityInput = document.querySelector('input[name=city]');
    const ul = document.querySelector('ul');

    btn.addEventListener('click', function () {
      const pname = provinceInput.value
      const cname = cityInput.value
      axios({
          url: 'http://ajax-api.itheima.net/api/area',
          method: 'GET',
          params: {
            // pname:pname,
            // cname:cname, 键值对一样可以简写
            pname,
            cname,
          },
        }).then(({ data: res }) => {
          // console.log(res);
          const {data} = res
          ul.innerHTML = data.map(item=>{
            return `<li>${item}</li>`
          }).join('')
        })
    })
  </script>
</body>

</html>